package com.scu.baseline.config;

import com.scu.baseline.interceptor.LoginHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//@Configuration
public class LoginInterceptorConfig implements WebMvcConfigurer {
    // 将登录拦截器配置到容器中
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginHandlerInterceptor())   // 如果用户被拦截，那么拦截之后的处理有这里定义的文件决定
                .addPathPatterns("/**");                  // 任意的请求都会被拦截
//                .excludePathPatterns("/",                   // 在此配置项出现的地址，都不会被拦截(放行原则)
//                        "/login.html"
//                        "/user/login",
//                        "/css/**",
//                        "/images/**",
//                        "/img/**",
//                        "/jquery/**",
//                        "/js/**",
//                        "/layui/**",
//                        "/swagger-resources/**",
//                        "/webjars/**",
//                        "/v2/**",
//                        "/swagger-ui.html/**"
//                );
    }

    // 配置视图跳转
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
//        registry.addViewController("/").setViewName("index");
//        registry.addViewController("/login.html").setViewName("index");
    }
}
